package com.ssh;

import org.junit.Test;

public class IsPalindrome_9 {
	public boolean isPalindrome(int x) {
        String s = String.valueOf(x);
        int l,r;
        int n = s.length();
        l = (n % 2 != 0) ? (n / 2) : (n / 2) - 1;
        r = n / 2;
        while (l >= 0 && s.charAt(l) == s.charAt(r)) {
        	l--;
        	r++;
        }
        if (l >= 0) {
        	return false;
        }else {
        	return true;
        }
    }
	
	public boolean isPalindrome1 (int x) {
		if (x < 0) {
			return false;
		}
		int y = x;
		int res = 0;
		while (y != 0) {
			res = res * 10 + y % 10;
			y /= 10;
		}
		return x == res;
		
	}
	@Test
	public void test () {
		System.out.println(isPalindrome(998));
	}
}
